package main

import "fmt"

type treeNode struct {
	value       int
	left, reght *treeNode
}

func (node treeNode) print() {
	fmt.Print(node.value, " ")
}

func (node *treeNode) setValue(value int) {
	node.value = value
}

// 遍历
func (node *treeNode) traverse() {
	if node == nil {
		return
	}

	node.left.traverse()
	node.print()
	node.reght.traverse()
}

func createNode(value int) *treeNode {
	return &treeNode{value: value}
}

func main() {
	var root treeNode

	root = treeNode{value: 3}
	root.left = &treeNode{}
	root.reght = &treeNode{5, nil, nil}
	root.reght.left = new(treeNode)
	root.left.reght = createNode(2)

	root.reght.left.setValue(6)
	root.reght.left.print()
	fmt.Println()

	root.traverse()
}
